package tbs.framework.async.task.container.impl

import tbs.framework.async.container.IAsyncTaskBroker
import tbs.framework.async.container.IAsyncTaskService
import tbs.framework.async.container.model.AsyncTaskDetail
import java.util.concurrent.ExecutorService


open class ThreadPoolTaskExecutor(private val executorService: ExecutorService) :
    IAsyncTaskBroker {
    override fun execute(task: AsyncTaskDetail, service: IAsyncTaskService) {
        executorService.execute {
            super.execute(task, service)
        }
    }

    override fun onTaskFinish(task: AsyncTaskDetail, service: IAsyncTaskService) {
    }

    override fun beforeExecute(task: AsyncTaskDetail, service: IAsyncTaskService) {

    }

    override fun afterExecute(task: AsyncTaskDetail, service: IAsyncTaskService) {

    }

    override fun onTaskFail(
        task: AsyncTaskDetail,
        service: IAsyncTaskService,
        e: Throwable,
        state: IAsyncTaskBroker.TaskState?
    ) {
    }
}